﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HerGoS.Administration.Entities;
using HerGoS.Administration.Engine;
using HerGoS.ControlsUI;

namespace HerGoS.WebUI
{
    public partial class Jurisdiccion_ABM : PageBase
    {
      
        #region Propiedades

        public Jurisdiccion Jurisdiccion
        {
            get
            {
                if (ViewState["Jurisdiccion"] != null)
                    return (Jurisdiccion)ViewState["Jurisdiccion"];
                return null;
            }
            set
            {
                ViewState["Jurisdiccion"] = value;
            }

        }

        #endregion


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["id"] == null)
                {
                    Jurisdiccion = new Jurisdiccion();
                }
                else
                {
                    var Id = Convert.ToInt32(Request.QueryString["id"]);
                    Jurisdiccion = GestorJurisdicciones.Obtener(Id);
                    this.txtCodigo.Text = Jurisdiccion.Codigo;
                    this.txtDescripcion.Text = Jurisdiccion.Descripcion;
                }
                Initialize();
            }

        }

        void Initialize()
        {
            this.btnGuardar.Settings(new ButtonExtText());
            this.btnCerrar.Settings(new ButtonExtText());
            LoadAutoria(Jurisdiccion);
        }

        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            Jurisdiccion.Codigo = this.txtCodigo.Text;
            Jurisdiccion.Descripcion = this.txtDescripcion.Text;

            GestorJurisdicciones.Guardar(Jurisdiccion);

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "closedialog", "parent.IntervaloCerrarPopup();", true);

        }


        protected void btnCerrar_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "closedialog", "parent.CerrarPopup();", true);
        }

    }
}